package cn.edu.gxu.xingjian.teacherassistant.web;

import cn.edu.gxu.xingjian.teacherassistant.domain.Classes;
import cn.edu.gxu.xingjian.teacherassistant.domain.Curriculum;
import cn.edu.gxu.xingjian.teacherassistant.domain.Faculty;
import cn.edu.gxu.xingjian.teacherassistant.domain.Grade;
import cn.edu.gxu.xingjian.teacherassistant.domain.Major;
import cn.edu.gxu.xingjian.teacherassistant.domain.PatternRole;
import cn.edu.gxu.xingjian.teacherassistant.domain.Syllabus;
import cn.edu.gxu.xingjian.teacherassistant.domain.Teacher;
import cn.edu.gxu.xingjian.teacherassistant.domain.TeachingMode;
import org.springframework.beans.factory.annotation.Configurable;
import org.springframework.core.convert.converter.Converter;
import org.springframework.format.FormatterRegistry;
import org.springframework.format.support.FormattingConversionServiceFactoryBean;
import org.springframework.roo.addon.web.mvc.controller.converter.RooConversionService;

@Configurable
/**
 * A central place to register application converters and formatters. 
 */
@RooConversionService
public class ApplicationConversionServiceFactoryBean extends FormattingConversionServiceFactoryBean {

	@Override
	protected void installFormatters(FormatterRegistry registry) {
		super.installFormatters(registry);
		// Register application converters and formatters
	}

	public Converter<Classes, String> getClassesToStringConverter() {
        return new org.springframework.core.convert.converter.Converter<cn.edu.gxu.xingjian.teacherassistant.domain.Classes, java.lang.String>() {
            public String convert(Classes classes) {
                return new StringBuilder().append(classes.getClassesName()).toString();
            }
        };
    }

	public Converter<Long, Classes> getIdToClassesConverter() {
        return new org.springframework.core.convert.converter.Converter<java.lang.Long, cn.edu.gxu.xingjian.teacherassistant.domain.Classes>() {
            public cn.edu.gxu.xingjian.teacherassistant.domain.Classes convert(java.lang.Long id) {
                return Classes.findClasses(id);
            }
        };
    }

	public Converter<String, Classes> getStringToClassesConverter() {
        return new org.springframework.core.convert.converter.Converter<java.lang.String, cn.edu.gxu.xingjian.teacherassistant.domain.Classes>() {
            public cn.edu.gxu.xingjian.teacherassistant.domain.Classes convert(String id) {
                return getObject().convert(getObject().convert(id, Long.class), Classes.class);
            }
        };
    }

	public Converter<Curriculum, String> getCurriculumToStringConverter() {
        return new org.springframework.core.convert.converter.Converter<cn.edu.gxu.xingjian.teacherassistant.domain.Curriculum, java.lang.String>() {
            public String convert(Curriculum curriculum) {
                return new StringBuilder().append(curriculum.getName()).append(' ').append(curriculum.getCredit()).append(' ').append(curriculum.getTeachingHours()).toString();
            }
        };
    }

	public Converter<Long, Curriculum> getIdToCurriculumConverter() {
        return new org.springframework.core.convert.converter.Converter<java.lang.Long, cn.edu.gxu.xingjian.teacherassistant.domain.Curriculum>() {
            public cn.edu.gxu.xingjian.teacherassistant.domain.Curriculum convert(java.lang.Long id) {
                return Curriculum.findCurriculum(id);
            }
        };
    }

	public Converter<String, Curriculum> getStringToCurriculumConverter() {
        return new org.springframework.core.convert.converter.Converter<java.lang.String, cn.edu.gxu.xingjian.teacherassistant.domain.Curriculum>() {
            public cn.edu.gxu.xingjian.teacherassistant.domain.Curriculum convert(String id) {
                return getObject().convert(getObject().convert(id, Long.class), Curriculum.class);
            }
        };
    }

	public Converter<Faculty, String> getFacultyToStringConverter() {
        return new org.springframework.core.convert.converter.Converter<cn.edu.gxu.xingjian.teacherassistant.domain.Faculty, java.lang.String>() {
            public String convert(Faculty faculty) {
                return new StringBuilder().append(faculty.getName()).toString();
            }
        };
    }

	public Converter<Long, Faculty> getIdToFacultyConverter() {
        return new org.springframework.core.convert.converter.Converter<java.lang.Long, cn.edu.gxu.xingjian.teacherassistant.domain.Faculty>() {
            public cn.edu.gxu.xingjian.teacherassistant.domain.Faculty convert(java.lang.Long id) {
                return Faculty.findFaculty(id);
            }
        };
    }

	public Converter<String, Faculty> getStringToFacultyConverter() {
        return new org.springframework.core.convert.converter.Converter<java.lang.String, cn.edu.gxu.xingjian.teacherassistant.domain.Faculty>() {
            public cn.edu.gxu.xingjian.teacherassistant.domain.Faculty convert(String id) {
                return getObject().convert(getObject().convert(id, Long.class), Faculty.class);
            }
        };
    }

	public Converter<Grade, String> getGradeToStringConverter() {
        return new org.springframework.core.convert.converter.Converter<cn.edu.gxu.xingjian.teacherassistant.domain.Grade, java.lang.String>() {
            public String convert(Grade grade) {
                return new StringBuilder().append(grade.getGradeName()).toString();
            }
        };
    }

	public Converter<Long, Grade> getIdToGradeConverter() {
        return new org.springframework.core.convert.converter.Converter<java.lang.Long, cn.edu.gxu.xingjian.teacherassistant.domain.Grade>() {
            public cn.edu.gxu.xingjian.teacherassistant.domain.Grade convert(java.lang.Long id) {
                return Grade.findGrade(id);
            }
        };
    }

	public Converter<String, Grade> getStringToGradeConverter() {
        return new org.springframework.core.convert.converter.Converter<java.lang.String, cn.edu.gxu.xingjian.teacherassistant.domain.Grade>() {
            public cn.edu.gxu.xingjian.teacherassistant.domain.Grade convert(String id) {
                return getObject().convert(getObject().convert(id, Long.class), Grade.class);
            }
        };
    }

	public Converter<Major, String> getMajorToStringConverter() {
        return new org.springframework.core.convert.converter.Converter<cn.edu.gxu.xingjian.teacherassistant.domain.Major, java.lang.String>() {
            public String convert(Major major) {
                return new StringBuilder().append(major.getMajorName()).toString();
            }
        };
    }

	public Converter<Long, Major> getIdToMajorConverter() {
        return new org.springframework.core.convert.converter.Converter<java.lang.Long, cn.edu.gxu.xingjian.teacherassistant.domain.Major>() {
            public cn.edu.gxu.xingjian.teacherassistant.domain.Major convert(java.lang.Long id) {
                return Major.findMajor(id);
            }
        };
    }

	public Converter<String, Major> getStringToMajorConverter() {
        return new org.springframework.core.convert.converter.Converter<java.lang.String, cn.edu.gxu.xingjian.teacherassistant.domain.Major>() {
            public cn.edu.gxu.xingjian.teacherassistant.domain.Major convert(String id) {
                return getObject().convert(getObject().convert(id, Long.class), Major.class);
            }
        };
    }

	public Converter<PatternRole, String> getPatternRoleToStringConverter() {
        return new org.springframework.core.convert.converter.Converter<cn.edu.gxu.xingjian.teacherassistant.domain.PatternRole, java.lang.String>() {
            public String convert(PatternRole patternRole) {
                return new StringBuilder().append(patternRole.getPatternRoles()).toString();
            }
        };
    }

	public Converter<Long, PatternRole> getIdToPatternRoleConverter() {
        return new org.springframework.core.convert.converter.Converter<java.lang.Long, cn.edu.gxu.xingjian.teacherassistant.domain.PatternRole>() {
            public cn.edu.gxu.xingjian.teacherassistant.domain.PatternRole convert(java.lang.Long id) {
                return PatternRole.findPatternRole(id);
            }
        };
    }

	public Converter<String, PatternRole> getStringToPatternRoleConverter() {
        return new org.springframework.core.convert.converter.Converter<java.lang.String, cn.edu.gxu.xingjian.teacherassistant.domain.PatternRole>() {
            public cn.edu.gxu.xingjian.teacherassistant.domain.PatternRole convert(String id) {
                return getObject().convert(getObject().convert(id, Long.class), PatternRole.class);
            }
        };
    }

	public Converter<Syllabus, String> getSyllabusToStringConverter() {
        return new org.springframework.core.convert.converter.Converter<cn.edu.gxu.xingjian.teacherassistant.domain.Syllabus, java.lang.String>() {
            public String convert(Syllabus syllabus) {
                return new StringBuilder().append(syllabus.getSemester()).toString();
            }
        };
    }

	public Converter<Long, Syllabus> getIdToSyllabusConverter() {
        return new org.springframework.core.convert.converter.Converter<java.lang.Long, cn.edu.gxu.xingjian.teacherassistant.domain.Syllabus>() {
            public cn.edu.gxu.xingjian.teacherassistant.domain.Syllabus convert(java.lang.Long id) {
                return Syllabus.findSyllabus(id);
            }
        };
    }

	public Converter<String, Syllabus> getStringToSyllabusConverter() {
        return new org.springframework.core.convert.converter.Converter<java.lang.String, cn.edu.gxu.xingjian.teacherassistant.domain.Syllabus>() {
            public cn.edu.gxu.xingjian.teacherassistant.domain.Syllabus convert(String id) {
                return getObject().convert(getObject().convert(id, Long.class), Syllabus.class);
            }
        };
    }

	public Converter<Teacher, String> getTeacherToStringConverter() {
        return new org.springframework.core.convert.converter.Converter<cn.edu.gxu.xingjian.teacherassistant.domain.Teacher, java.lang.String>() {
            public String convert(Teacher teacher) {
                return new StringBuilder().append(teacher.getName()).append(' ').append(teacher.getAge()).append(' ').append(teacher.getWorkingNumber()).append(' ').append(teacher.getSex()).toString();
            }
        };
    }

	public Converter<Long, Teacher> getIdToTeacherConverter() {
        return new org.springframework.core.convert.converter.Converter<java.lang.Long, cn.edu.gxu.xingjian.teacherassistant.domain.Teacher>() {
            public cn.edu.gxu.xingjian.teacherassistant.domain.Teacher convert(java.lang.Long id) {
                return Teacher.findTeacher(id);
            }
        };
    }

	public Converter<String, Teacher> getStringToTeacherConverter() {
        return new org.springframework.core.convert.converter.Converter<java.lang.String, cn.edu.gxu.xingjian.teacherassistant.domain.Teacher>() {
            public cn.edu.gxu.xingjian.teacherassistant.domain.Teacher convert(String id) {
                return getObject().convert(getObject().convert(id, Long.class), Teacher.class);
            }
        };
    }

	public Converter<TeachingMode, String> getTeachingModeToStringConverter() {
        return new org.springframework.core.convert.converter.Converter<cn.edu.gxu.xingjian.teacherassistant.domain.TeachingMode, java.lang.String>() {
            public String convert(TeachingMode teachingMode) {
                return new StringBuilder().append(teachingMode.getMode()).toString();
            }
        };
    }

	public Converter<Long, TeachingMode> getIdToTeachingModeConverter() {
        return new org.springframework.core.convert.converter.Converter<java.lang.Long, cn.edu.gxu.xingjian.teacherassistant.domain.TeachingMode>() {
            public cn.edu.gxu.xingjian.teacherassistant.domain.TeachingMode convert(java.lang.Long id) {
                return TeachingMode.findTeachingMode(id);
            }
        };
    }

	public Converter<String, TeachingMode> getStringToTeachingModeConverter() {
        return new org.springframework.core.convert.converter.Converter<java.lang.String, cn.edu.gxu.xingjian.teacherassistant.domain.TeachingMode>() {
            public cn.edu.gxu.xingjian.teacherassistant.domain.TeachingMode convert(String id) {
                return getObject().convert(getObject().convert(id, Long.class), TeachingMode.class);
            }
        };
    }

	public void installLabelConverters(FormatterRegistry registry) {
        registry.addConverter(getClassesToStringConverter());
        registry.addConverter(getIdToClassesConverter());
        registry.addConverter(getStringToClassesConverter());
        registry.addConverter(getCurriculumToStringConverter());
        registry.addConverter(getIdToCurriculumConverter());
        registry.addConverter(getStringToCurriculumConverter());
        registry.addConverter(getFacultyToStringConverter());
        registry.addConverter(getIdToFacultyConverter());
        registry.addConverter(getStringToFacultyConverter());
        registry.addConverter(getGradeToStringConverter());
        registry.addConverter(getIdToGradeConverter());
        registry.addConverter(getStringToGradeConverter());
        registry.addConverter(getMajorToStringConverter());
        registry.addConverter(getIdToMajorConverter());
        registry.addConverter(getStringToMajorConverter());
        registry.addConverter(getPatternRoleToStringConverter());
        registry.addConverter(getIdToPatternRoleConverter());
        registry.addConverter(getStringToPatternRoleConverter());
        registry.addConverter(getSyllabusToStringConverter());
        registry.addConverter(getIdToSyllabusConverter());
        registry.addConverter(getStringToSyllabusConverter());
        registry.addConverter(getTeacherToStringConverter());
        registry.addConverter(getIdToTeacherConverter());
        registry.addConverter(getStringToTeacherConverter());
        registry.addConverter(getTeachingModeToStringConverter());
        registry.addConverter(getIdToTeachingModeConverter());
        registry.addConverter(getStringToTeachingModeConverter());
    }

	public void afterPropertiesSet() {
        super.afterPropertiesSet();
        installLabelConverters(getObject());
    }
}
